package view;
import db.LoadAll;
import model.Auction;
import model.Product;

/**
 *
 * @author Morten
 */
public class SearchResult extends javax.swing.JPanel {
    private LoadAll load;
    private Product product;
    private int bid;

    /**
     * Creates new form SearchResult
     * @param auction
     * @param load
     */
    public SearchResult(Auction auction,LoadAll load){
	initComponents();
	this.load=load;
	product=auction.getProduct();
	jLabelName.setText(product.getName());
	jLabelEndtime.setText(auction.getEndtime());
	if(load.getBidList(auction).size()>0){
	    bid = load.getBidList(auction).get(0).getAmount();
	}else{
	    bid = auction.getStartingbid();
	}
	jLabelBid.setText(bid+" kr.");
    }
    public SearchResult(String mode){
	initComponents();
	jLabelName.setText("");
	jLabelEndtime.setText("");
	jLabelBid.setText("");
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabelName = new javax.swing.JLabel();
        jLabelEndtime = new javax.swing.JLabel();
        jLabelBid = new javax.swing.JLabel();

        jLabelName.setText("---");

        jLabelEndtime.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
        jLabelEndtime.setText("---");

        jLabelBid.setText("---");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabelName, javax.swing.GroupLayout.DEFAULT_SIZE, 182, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabelEndtime, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabelBid, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(13, 13, 13))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelName)
                    .addComponent(jLabelEndtime)
                    .addComponent(jLabelBid))
                .addGap(0, 0, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabelBid;
    private javax.swing.JLabel jLabelEndtime;
    private javax.swing.JLabel jLabelName;
    // End of variables declaration//GEN-END:variables
}
